<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/view/common/taglibs.jsp" %>
<script type="text/javascript">
<!--
function checkSubmit(){
    $("#msgShow")[0].innerHTML="&nbsp;"; 
    var isSub = true;
    var paramStr = [];
    $(".appClass").each(function() {
        var param ="";
        if($(this).attr("type")=='radio'){
           if($(this).attr("checked")){
              param = '"'+$(this).attr("app_field") +'":"'+ $(this).val()+'"';
           }
        }if($(this).attr("type")=='textarea'){
           param = '"'+replaceStr($(this).attr("app_field")) +'":"'+ replaceStr($(this).val())+'"';
        }else{
           if($(this).attr("is_empty") == 0){//不为空的判断
              if($(this).val() == ""){
                 $("#msgShow")[0].innerHTML = $(this).attr("field_name")+"不能为空";
                 isSub = false;
                 return false;
              }
              param = '"'+replaceStr($(this).attr("app_field")) +'":"'+ replaceStr($(this).val())+'"';
           }
		}
		//alert(param);
		if(param != ""){
		   paramStr.push(param);
		}
	});
	if(isSub){//满足条件后提交
	   $('#appConfigAppKey').attr('value', '${entity.configTypeKey}');
	   $('#appConfigConfigValue').attr('value', paramStr);
	   var appId = $("#appId").val();//当修改配置是获取 该应用的id
	   if(appId){//表示是修改
	       $('#appConfigId').attr('value', appId);
	       $("#form1").attr("action", "${contextPath}/system/preferences/update.do");
	   }else{
	       $("#form1").attr("action", "${contextPath}/system/preferences/create.do");
	   }
	   //$("#form1").submit();
	   return true;
	}
	
	return false;
}

function subReset(){
	window.location = "edit.do?entity.configTypeKey=1-1";
   //$("input[type='text']").each(function(){
//	   $(this).val(5);
 //  });
}

function SelectTemplets(fname){
	if(document.all){
		var posLeft = window.event.clientY-100;
		var posTop = window.event.clientX-400;
	}else{
		var posLeft = 100;
		var posTop = 100;
	}
	window.open("${contextPath}/core/fileManager/selectTemplate.do?targetInput="+fname, "poptempWin", "scrollbars=yes,resizable=yes,statebar=no,width=600,height=400,left="+posLeft+", top="+posTop);
}

//json数据过滤特殊字符【\r\n 和 " 和 \】
function replaceStr(str){
    str = str.replace(/[\r\n]/g, '$br$;').replace(/[\\]/g, '\\\\').replace(/["]/g, '\\"');
    return str;
}
//-->
</script>
<table width="98%" border="0" cellpadding="3" cellspacing="1" bgcolor="#D1DDAA" align="center">
		<tr align="center" height="25" bgcolor="#FDFEE9">
			<td width="35%">参数说明</td>
			<td width="45%">参数值</td>
		</tr>
		<s:property value="jsonText" escape="false" />
</table>

    <div width='100%' height="25"  align="center"  style="margin-bottom: 5px;"><font color="red" id="msgShow">&nbsp;</font></div>
    	<form id="form1" name="form1" onsubmit="return checkSubmit();" method="post">	
		    <input type="hidden" id="appConfigId" name="entity.id">
		    <input type="hidden" id="appConfigAppKey" name="entity.configTypeKey">
		    <input type="hidden" id="appConfigConfigValue" name="entity.configValue">
	  	
		 <table width="100%">
	            	<tr>
	                	<td><div align="center">
	                	  <input type="submit" name="submit" value="" class="btn_save"  />
	                	&nbsp;&nbsp;
	                      <input type="button" name="reset" value="" class="btn_rest" onclick="subReset()"/>
	                    </div>
	                    </td>
	                </tr>
	     </table>       
       </form> 